<?php
/**
 * DishForm class.
 * DishForm is the data structure for keeping merchant menu item for dish.
 * It is used by the 'form', 'preview' action of 'MenuController'.
 * 
 * Yawii 版权所有 @ 2012
 */
class DishForm extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return ShopProfile the static model class
	 */
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName() {
		return 'tbl_merchant_menu_item';
	}

	/**
	 * Declares the validation rules.
	 */
	public function rules() {
		return array(
			// fields are required
			array('name, price', 'required'),
			array('price', 'numerical'),
			array('name', 'length', 'max'=>256),
			array('number, description, price_flexible, url_picture', 'safe'),
		);
	}

	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels() {
		return array(
			'id_category' => BUtils::T('dish_category_lbl'),
			'url_picture' => BUtils::T('dish_photo_lbl'),
			'number' => 'No.',
			'name' => BUtils::T('dish_name_lbl'),
			'description' => BUtils::T('dish_description_lbl'),
			'featured' => BUtils::T('dish_featured_lbl'),
			'price' => BUtils::T('dish_price_lbl'),
			'submitted_time' => BUtils::T('submitted_time_lbl'),
			'published_time' => BUtils::T('published_time_lbl'),
		);
	}
}
